stata命令汇总

您所在的位置:网站首页 stata sem命令 stata命令汇总

stata命令汇总

#stata命令汇总| 来源: 网络整理| 查看: 265

ff3cf4a0d212311abe452bb6bccf5c2b.png

推荐阅读: Stata寒假研讨班_2020年1月_第13&14届“高级计量经济学及stata应用”研讨班@上海/北京专场_ 火热报名中 一分钟看完stata模型汇总入门命令 1 基本命令 基本描述统计分析语法格式为: sysuse "auto.dta", clear //打开auto美国1978年汽车行业横截面数据sum price mpg rep78 weight ,detailpwcorr price mpg rep78 weight pwcorr price mpg rep78 weight ,sig star(0.05) 2 横截面分析 回归分析 use nerlove.dta,clearreg lntc lnpf lnpk lnpl reg lntc lnpf lnpk lnpl ,nocpredict yhat // 拟合被解释变量GDPpredict e,residual // 计算残差rvfplot   参数检验 regress lntc lnpk lnpltest lnpk=0.5                      //检验系数test lnpk=lnplestat hettest //异方差BP检验estat imtest,white //异方差white检验estat vif //多重共线性检验 带约束条件检验 cons 1 lnpk+lnpl=1cons 2 lnpk+lnpl=1.6cnsreg lntc lnpk lnpl,constraints(1) //有约束的回归cnsreg lntc lnpk lnpl,constraints(2) //有约束的回归bootstrap, reps(200):regress lntc lnpk lnpl //bootstrap 方法的回归bootstrap _b :regress lntc lnpk lnpl //bootstrap 方法的回归 稳健回归 regress lntc lnpk lnplestimates store model1reg lntc lnpk lnpl,robustestimates store model2esttab model* using huigui.rtf,r2 ar2 nogap replace 3 时间序列模型 时间序列声明 use 时间序列数据.dta, cleartsset year   //时间序列声明 单位根检验 use 时间序列数据.dta, cleardfuller d.m,lag(2)                //ADF检验dfuller m,nocon regress //ADF检验dfuller m,trend regresspperron m,lag(2)                  //PP检验                   pperron m,nocon regress pperron d.m,regressdfgls m //DF-GLS检验kpss m,notrend //KPSS检验 ECM单位根检验 reg m s g estimates store model1predict ecm,residualreg d.m d.s d.g ecm //ECM模型 VAR模型 varsoc m s g ,maxlag(5)var m s g ,lags(1/4)varstable,graphvargrangerirf create myrif,set(myrif) replaceirf graph irf VECM模型 vecrank m s g,lags(4)varsoc m s g,maxlag(5)vec m s g,lags(4) reg m s g vecstable,graph 4 面板模型 面板声明 use FDI.dtar, clearxtset id yearxtdesxtline lngdp 单位根检验 xtunitroot llc lngdp,lags(2) trendxtunitroot llc d.lngdp,lags(2) trendxtunitroot ips lngdpxtunitroot ips d.lngdp 协整检验 xtwest lngdp lnfdi lni,lags(2) 混合回归 reg lngdp lnfdi lniereg lngdp lnfdi lnie,robustreg lngdp lnfdi lnie,vce(cluster id) 固定效应 xtreg lngdp lnfdi lnie lnex lnim lnci lngp,fextreg lngdp lnfdi lnie lnex lnim lnci lngp,fe,fe vce (cluster id)xi:xtreg lngdp lnfdi lnie lnex lnim lnci lngp i.id,vce(cluster id) //LSDV 考虑个体固定效应tab year,gen(year)xtreg lngdp lnfdi lnie lnex lnim lnci lngp year2-year14,fe xtreg lngdp lnfdi lnie lnex lnim lnci lngp year2-year14,fe vce (cluster id)test year2=year3=year4=year5=0 随机效应 xtreg lngdp lnfdi lnie lnex lnim lnci lngp,re mlextreg lngdp lnfdi lnie lnex lnim lnci lngp,vce (cluster id) xtreg lngdp lnfdi lnie lnex lnim lnci lngp,re mle //随机效应的MLE参数估计方法 Hausman检验--随机和固定效应的检验 xtreg lngdp lnfdi lnie lnex lnim lnci lngp,reest store rextreg lngdp lnfdi lnie lnex lnim  lnci lngp,feest store fehausman fe reest table re fe, b(%6.3f) star(0.1 0.05 0.01) outreg2 [fe re] using daqinxueshu.doc,stats(coef,tstat) addstat(Ajusted R2,`e(r2_a)') replace

一文读懂108个常用stata命令

Some useful Stata commands

help : online help on a specific command

findit : online references on a keyword or topic

ssc : access routines from the SSC Archive

pwd : print the working directory

cd : change the working directory

log : log output to an external file

tsset : define the time indicator for timeseries or panel data

compress : economize on space used by variables

clear : clear memory

quietly : do not show the results of a command

update query : see if Stata is up to date

adoupdate : see if user-written commands are up to date

exit : exit the program (,clear if dataset is not saved)

 Data manipulation commands

generate : create a new variable

describe : describe a data set or current contents of memory

replace : modify an existing variable

rename : rename variable

renvars : rename a set of variables

sort : change the sort order of the dataset

drop : drop certain variables and/or observations

keep : keep only certain variables and/or observations

append : combine datasets by stacking

merge : merge datasets (one-to-one or match merge)

encode : generate numeric variable from categorical variable

recode : recode categorical variable

destring : convert string variables to numeric

foreach : loop over elements of a list, performing a block of code

forvalues : loop over a numlist, performing a block of code

local : define or modify a local macro (scalar variable)

use : load a Stata data set

save : write the contents of memory to a Stata data set

insheet : load a text file in tab- or comma-delimited format

infile : load a text file in space-delimited format or as defined in a

dictionary

outfile : write a text file in space- or comma-delimited format

outsheet : write a text file in tab- or comma-delimited format

contract : make a dataset of frequencies

collapse : make a dataset of summary statistics

tab : abbreviation for tabulate: 1- and 2-way tables

table : tables of summary statistics

Statistical commands

summarize : descriptive statistics

correlate : correlation matrices

ttest : perform 1-, 2-sample and paired t-tests

anova : 1-, 2-, n-way analysis of variance

regress : least squares regression

predict : generate fitted values, residuals, etc.

test : test linear hypotheses on parameters

lincom : linear combinations of parameters

cnsreg : regression with linear constraints

testnl : test nonlinear hypothesis on parameters

margins : marginal effects (elasticities, etc.)

ivregress : instrumental variables regression

prais : regression with AR(1) errors

sureg : seemingly unrelated regressions

reg3 : three-stage least squares

qreg : quantile regression

Limited dependent variable estimation commands

logit, logistic : logit model, logistic regression

probit : binomial probit model

tobit : one- and two-limit Tobit model

cnsreg : Censored normal regression (generalized Tobit)

ologit, oprobit : ordered logit and probit models

mlogit : multinomial logit model

poisson : Poisson regression

heckman : selection model

 Time series estimation commands

arima : Box–Jenkins models, regressions with ARMA errors

arfima : Box–Jenkins models with long memory errors

arch : models of autoregressive conditional heteroskedasticity

dfgls : unit root tests

corrgram : correlogram estimation

var : vector autoregressions (basic and structural)

irf : impulse response functions, variance decompositions

vec : vector error–correction models (cointegration)

sspace : state-space models

dfactor : dynamic factor models

ucm : unobserved-components models

rolling: prefix permitting rolling or recursive estimation over subsets

 Panel data estimation commands

xtreg,fe : fixed effects estimator

xtreg,re : random effects estimator

xtgls : panel-data models using generalized least squares

xtivreg : instrumental variables panel data estimator

xtlogit : panel-data logit models

xtprobit : panel-data probit models

xtpois : panel-data Poisson regression

xtgee : panel-data models using generalized estimating equations

xtmixed : linear mixed (multi-level) models

xtabond : Arellano-Bond dynamic panel data estimator



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3